<style lang="less" scoped>
  .report-situation{
    width: 100%;
    height: 100%;
    &_content{
      height: calc(100% - 119px);
      overflow-y: auto;
    }
    .dignosis-content{
      width: 100%;
      height: 400px;
      display: inline-block;
      .dignosis-style{
        display: inline-block;
        width: 50%;
        height: 100%;
      }
    }
    .box-card + .box-card{
      margin-top: 5px;
    }
    /deep/.el-radio__label{
      line-height: 38px;
    }
  }
</style>

<template>
  <div class="report-situation">
    <!-- <el-form inline>
      <el-radio v-model="radioDate" label="1" @change="changeDate">
        <span style="margin-right: 5px;">指定日期</span>
        <el-form-item label="年份：">
          <el-date-picker
            v-model="year"
            type="year"
            value-format="yyyy"
            size="mini"
            :disabled="radioDate == 2"
            placeholder="选择年"
          />
        </el-form-item>
        <el-form-item label="季度：">
          <el-select v-model="quarter" size="mini" placeholder="请选择" :disabled="radioDate == 2">
            <el-option label="第一季度" :value="1" />
            <el-option label="第二季度" :value="2" />
            <el-option label="第三季度" :value="3" />
            <el-option label="第四季度" :value="4" />
          </el-select>
        </el-form-item>
        <el-form-item label="月份：">
          <el-select v-model="month" size="mini" placeholder="请选择" :disabled="radioDate == 2">
            <el-option label="一月" :value="1" :disabled="quarter != '' && quarter != '1'" />
            <el-option label="二月" :value="2" :disabled="quarter != '' && quarter != '1'" />
            <el-option label="三月" :value="3" :disabled="quarter != '' && quarter != '1'" />
            <el-option label="四月" :value="4" :disabled="quarter != '' && quarter != '2'" />
            <el-option label="五月" :value="5" :disabled="quarter != '' && quarter != '2'" />
            <el-option label="六月" :value="6" :disabled="quarter != '' && quarter != '2'" />
            <el-option label="七月" :value="7" :disabled="quarter != '' && quarter != '3'" />
            <el-option label="八月" :value="8" :disabled="quarter != '' && quarter != '3'" />
            <el-option label="九月" :value="9" :disabled="quarter != '' && quarter != '3'" />
            <el-option label="十月" :value="10" :disabled="quarter != '' && quarter != '4'" />
            <el-option label="十一月" :value="11" :disabled="quarter != '' && quarter != '4'" />
            <el-option label="十二月" :value="12" :disabled="quarter != '' && quarter != '4'" />
          </el-select>
        </el-form-item>
      </el-radio>
      <el-radio v-model="radioDate" label="2" @change="changeDate">
        <span style="margin-right: 5px;">其他时间</span>
        <el-form-item label="">
          <el-date-picker
            v-model="monthRange"
            type="monthrange"
            start-placeholder="开始月份"
            end-placeholder="结束月份"
            size="mini"
            format="yyyy-MM"
            value-format="yyyy-MM"
            :disabled="radioDate == 1"
          />
        </el-form-item>
      </el-radio>
      <el-form-item label="科室：">
        <el-select v-model="dept" placeholder="请选择" size="mini" @change="deptChange">
          <el-option
            v-for="(item, index) in deptList"
            :key="index"
            :label="item.name"
            :value="item.name"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="人员：">
        <el-select v-model="doc" placeholder="请选择" size="mini">
          <el-option
            v-for="(item, index) in docList"
            :key="index"
            :label="item.name"
            :value="item.name"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="">
        <el-button type="primary" size="mini" @click="search">搜索</el-button>
        <el-button size="mini" @click="reset">重置</el-button>
      </el-form-item>
    </el-form> -->
    <div class="report-situation_content">
      <el-card class="box-card">
        <div slot="header" class="clearfix">
          <span>上报趋势</span>
        </div>
        <div class="dignosis-content" style="position: relative;">
          <div style="position: absolute; left: 45%; top: -1%;line-height: 36px; z-index: 999;">

            <span style="height: 20px; line-height: 20px; font-weight: bold; font-size: 20px; display: inline-block;">上报完成数量趋势图</span>
            <el-popover
              placement="bottom"
              title="说明"
              width="400"
              trigger="hover"
            >
              <div>考核对象：</div>
              <div>所有胸痛病例</div>
              <div>数据取值：</div>
              <div>1.上报状态为建档上报的，统计病例数量</div>
              <div>2.展示变化趋势</div>
              <div>3.按月统计，无重复计算</div>
              <div>查询筛选：</div>
              <div>时间、全院、科室、人员</div>
              <i slot="reference" class="el-icon-info" style="color: #42cece;" />
            </el-popover>
          </div>
          <div id="report-averaget-time" style="width: 100%; height: 100%;" />
        </div>
        <div class="dignosis-content" style="position: relative;">
          <div style="position: absolute; left: 45%; top: -1%;line-height: 36px; z-index: 999;">
            <span style="height: 20px; line-height: 20px; font-weight: bold; font-size: 20px; display: inline-block;">上报平均耗时趋势图</span>
            <el-popover
              placement="bottom"
              title="说明"
              width="400"
              trigger="hover"
            >
              <div>考核对象：</div>
              <div>已建档上报的病例</div>
              <div>数据取值：</div>
              <div>1.取接诊时间和建档上报时间之差</div>
              <div>2.展示变化趋势</div>
              <div>3.按月统计，取平均值</div>
              <div>查询筛选：</div>
              <div>时间、全院、科室、人员</div>
              <i slot="reference" class="el-icon-info" style="color: #42cece;" />
            </el-popover>
          </div>
          <div id="reported-completed-quantity" style="width: 100%; height: 100%;" />
        </div>
      </el-card>
      <el-card class="box-card">
        <div slot="header" class="clearfix">
          <span>上报数量统计</span>
          <el-popover
            placement="bottom"
            title="说明"
            width="400"
            trigger="hover"
            style="margin-left: 5px;"
          >
            <div>考核对象：</div>
            <div>所有胸痛病例</div>
            <div>数据取值：</div>
            <div>1.填报情况分布图，分为“未上报”、“建档上报”</div>
            <div>①“未上报”，取已在系统建档，但未在官网建档上报的病例；</div>
            <div>②“建档上报”，取已在官网进行过建档上报的病例，包含建档上报、流程结束和最终上报的</div>
            <div>2.最终上报情况分布图，分为“流程结束”、“最终上报”</div>
            <div>①“流程结束”，取诊断为未明确诊断、非ACS心源性胸痛、其它非心源性胸痛、胸痛待查、胸闷待查的病例；</div>
            <div>②“最终上报”，取在系统中进行“最终上报”的病例</div>
            <div>查询筛选：</div>
            <div>时间、全院、科室、人员</div>
            <i slot="reference" class="el-icon-info" style="color: #42cece;" />
          </el-popover>
        </div>
        <div class="dignosis-content">
          <div id="information-fill" class="dignosis-style" />
          <div id="have-been-reported" class="dignosis-style" />
        </div>
      </el-card>
      <el-card class="box-card">
        <div slot="header" class="clearfix">
          <span>科室填报量排名</span>
          <el-popover
            placement="bottom"
            title="说明"
            width="400"
            trigger="hover"
            style="margin-left: 5px;"
          >
            <div>考核对象：</div>
            <div>已建档上报的病例</div>
            <div>数据取值：</div>
            <div>1.取建档数据</div>
            <div>2.按月统计，无重复计算</div>
            <div>查询筛选：</div>
            <div>时间、全院</div>
            <i slot="reference" class="el-icon-info" style="color: #42cece;" />
          </el-popover>
        </div>
        <div id="dept-fill" class="dignosis-content" />
      </el-card>
      <el-card class="box-card">
        <div slot="header" class="clearfix">
          <span>超期建档上报预警</span>
          <el-popover
            placement="bottom"
            title="说明"
            width="400"
            trigger="hover"
            style="margin-left: 5px;"
          >
            <div>考核对象：</div>
            <div>已建档且尚未在官网建档上报的病例</div>
            <div>数据取值：</div>
            <div>1.取入院时长</div>
            <div>2.由长到短排序，0~2天绿色（包含2天0小时），2~3天黄色（包含3天0小时），3天以上红色</div>
            <div>查询筛选：</div>
            <div>不支持筛选，默认显示所有预警指标</div>
            <i slot="reference" class="el-icon-info" style="color: #42cece;" />
          </el-popover>
        </div>
        <div class="dignosis-content">
          <el-table
            :data="exceedTimeData"
            height="400px"
            border
            style="width: 100%"
          >
            <el-table-column type="index" align="center" label="序号" width="80" />
            <el-table-column prop="patientName" align="center" label="患者姓名" />
            <el-table-column prop="inpatientNo" align="center" label="住院ID" />
            <el-table-column prop="receptionTime" align="center" label="接诊时间" />
            <el-table-column prop="inpatientDays" align="center" label="入院时长">
              <template slot-scope="scope">
                <span :style="{color: scope.row.level == 1 ? '#13ce66' : scope.row.level == 2 ? '#f3bf23' : scope.row.level == 3 ? '#f35523' : ''}">{{ scope.row.inpatientDays }}</span>
              </template>
            </el-table-column>
            <el-table-column prop="currentDepartment" align="center" label="当前科室" />
            <el-table-column prop="currentDoctor" align="center" label="当前医生" />
            <el-table-column align="center" label="操作">
              <template slot-scope="scope">
                <el-button type="text" @click="view(scope.row)">查看</el-button>
                <el-button type="text" @click="ignore(scope.row)">忽略</el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </el-card>
    </div>
  </div>
</template>

<script>
import echarts from 'echarts'
import {
  getDeptList,
  getDeptUserList,
  getUploadAvgMinutes,
  getUploadNums,
  getUploadQty,
  getUploadedQty,
  getDeptUploadNumRanking,
  getNotUploadList,
  ignoreUploadAlarm
} from '@/api/statistical/chest-pain'
export default {
  props: ['preYear', 'preQuarter', 'preMonth', 'preMonthRange', 'preDept', 'preDoc'],
  data() {
    const _this = this
    return {
      radioDate: '1',
      year: '',
      quarter: '',
      month: '',
      dept: '',
      doc: '',
      monthRange: [],
      pickerOptions: {
        disabledDate: time => {
          let year = ''
          if (_this.year) {
            year = _this.year
          } else {
            year = time.getFullYear()
          }
          const firstMonth = new Date(+year, 1)
          const lastMonth = new Date(+year, 1)
          if (_this.quarter) {
            if (_this.quarter == 1) {
              firstMonth.setMonth(0)
              lastMonth.setMonth(2)
            } else if (_this.quarter == 2) {
              firstMonth.setMonth(3)
              lastMonth.setMonth(5)
            } else if (_this.quarter == 3) {
              firstMonth.setMonth(6)
              lastMonth.setMonth(8)
            } else if (_this.quarter == 4) {
              firstMonth.setMonth(9)
              lastMonth.setMonth(11)
            }
          } else {
            firstMonth.setMonth(0)
            lastMonth.setMonth(11)
          }
          return time.getTime() < new Date(firstMonth).getTime() || time.getTime() > new Date(lastMonth).getTime()
        }
      },
      deptList: [],
      docList: [],
      exceedTimeData: []
    }
  },
  mounted() {
    // this.getReportedCompletedQuantity()
    // this.getReportAveragetTime()
    // this.getInformationFill()
    // this.getHaveBeenReported()
    // this.getDeptFill()
    // this.getDept()
    // this.getTableData()
  },
  methods: {
    getDept() {
      this.deptList = []
      getDeptList({
        hospitalId: this.$store.getters.hospitalId
      }).then(res => {
        if (res.code == 0) {
          if (res.data) {
            if (res.data.deptList && res.data.deptList.length > 0) {
              this.deptList = res.data.deptList
            }
          }
        }
      })
    },
    deptChange(val) {
      this.doc = ''
      this.docList = []
      getDeptUserList({
        hospitalId: this.$store.getters.hospitalId,
        departmentName: val
      }).then(res => {
        if (res.code == 0) {
          if (res.data) {
            if (res.data.deptUserList && res.data.deptUserList.length > 0) {
              this.docList = res.data.deptUserList
            }
          }
        }
      })
    },
    changeDate(val) {
      if (val == 1) {
        this.monthRange = []
      } else if (val == 2) {
        this.year = ''
        this.quarter = ''
        this.month = ''
      }
    },
    search() {
      this.year = this.preYear
      this.quarter = this.preQuarter
      this.month = this.preMonth
      this.monthRange = this.preMonthRange
      this.dept = this.preDept
      this.doc = this.preDoc
      this.getReportedCompletedQuantity()
      this.getReportAveragetTime()
      this.getInformationFill()
      this.getHaveBeenReported()
      this.getDeptFill()
    },
    reset() {
      this.search()
    },
    getReportedCompletedQuantity() {
      const reportedCompletedQuantity = document.getElementById('reported-completed-quantity')
      const myChart = echarts.init(reportedCompletedQuantity)
      myChart.clear()
      myChart.hideLoading()
      window.addEventListener('resize', myChart.resize)
      getUploadAvgMinutes({
        hospitalId: this.$store.getters.hospitalId,
        year: this.year,
        quarter: this.quarter,
        month: this.month,
        startTime: this.monthRange.length > 0 ? this.monthRange[0] : '',
        endTime: this.monthRange.length > 0 ? this.monthRange[1] : '',
        departmentName: this.dept,
        doctorName: this.doc
      }).then(res => {
        if (res.code == 0) {
          if (res.data) {
            const timeLine = []
            const minutesList = []
            if (res.data.uploadAvgMinutes && res.data.uploadAvgMinutes.length > 0) {
              res.data.uploadAvgMinutes.forEach(el => {
                const timeConcat = el.year + '-' + el.month
                timeLine.push(timeConcat)
                minutesList.push(el.uploadMinute ? el.uploadMinute : 0)
              })
              const option = {
                color: ['#027DB4'],
                title: {
                  text: '',
                  subtext: '',
                  left: 'center'
                },
                xAxis: {
                  name: '',
                  type: 'category',
                  data: timeLine
                },
                yAxis: {
                  name: '分钟',
                  type: 'value'
                },
                series: [
                  {
                    data: minutesList,
                    type: 'line',
                    label: {
                      show: true,
                      position: 'top',
                      formatter: params => {
                        let day = 0
                        let hour = 0
                        let mins = 0
                        day = parseInt(Number(params.value) / (24 * 60))
                        if (parseInt(params.value) > 60) {
                          const surplusHour = parseInt(Number(params.value) / 60)
                          if (surplusHour > 24) {
                            hour = parseInt(Number(surplusHour) % 24)
                          } else {
                            hour = surplusHour
                          }
                        } else {
                          hour = 0
                        }

                        mins = Number(params.value) % 60
                        return day + '天' + hour + '小时' + mins + '分钟'
                      }
                    },
                    smooth: true
                  }
                ]
              }
              myChart.setOption(option)
            } else {
              myChart.showLoading({
                text: '暂无数据',
                fontSize: 18,
                left: 'center',
                color: 'transparent', // loading颜色，设置成透明或白色，不然会显示loading状态
                textColor: '#000', // 文字颜色
                maskColor: 'rgba(255, 255, 255, 0)' // 背景色
              })
            }
          }
        } else {
          myChart.showLoading({
            text: '暂无数据',
            fontSize: 18,
            left: 'center',
            color: 'transparent', // loading颜色，设置成透明或白色，不然会显示loading状态
            textColor: '#000', // 文字颜色
            maskColor: 'rgba(255, 255, 255, 0)' // 背景色
          })
        }
      })
    },
    getReportAveragetTime() {
      const reportAveragetTime = document.getElementById('report-averaget-time')
      const myChart = echarts.init(reportAveragetTime)
      myChart.clear()
      myChart.hideLoading()
      window.addEventListener('resize', myChart.resize)
      getUploadNums({
        hospitalId: this.$store.getters.hospitalId,
        year: this.year,
        quarter: this.quarter,
        month: this.month,
        startTime: this.monthRange.length > 0 ? this.monthRange[0] : '',
        endTime: this.monthRange.length > 0 ? this.monthRange[1] : '',
        departmentName: this.dept,
        doctorName: this.doc
      }).then(res => {
        if (res.code == 0) {
          if (res.data) {
            const timeLine = []
            const uploadList = []
            if (res.data.uploadNums && res.data.uploadNums.length > 0) {
              res.data.uploadNums.forEach(el => {
                const timeConcat = el.year + '-' + el.month
                timeLine.push(timeConcat)
                uploadList.push(el.uploadNum ? el.uploadNum : 0)
              })

              const option = {
                color: ['#027DB4'],
                title: {
                  text: '',
                  subtext: '',
                  left: 'center'
                },
                xAxis: {
                  name: '',
                  type: 'category',
                  data: timeLine
                },
                yAxis: {
                  name: '例',
                  type: 'value'
                },
                series: [
                  {
                    data: uploadList,
                    type: 'line',
                    label: {
                      show: true,
                      position: 'top'
                    },
                    smooth: true
                  }
                ]
              }
              myChart.setOption(option)
            } else {
              myChart.showLoading({
                text: '暂无数据',
                fontSize: 18,
                left: 'center',
                color: 'transparent', // loading颜色，设置成透明或白色，不然会显示loading状态
                textColor: '#000', // 文字颜色
                maskColor: 'rgba(255, 255, 255, 0)' // 背景色
              })
            }
          }
        } else {
          myChart.showLoading({
            text: '暂无数据',
            fontSize: 18,
            left: 'center',
            color: 'transparent', // loading颜色，设置成透明或白色，不然会显示loading状态
            textColor: '#000', // 文字颜色
            maskColor: 'rgba(255, 255, 255, 0)' // 背景色
          })
        }
      })
    },
    getInformationFill() {
      const informationFill = document.getElementById('information-fill')
      const myChart = echarts.init(informationFill)
      myChart.clear()
      myChart.hideLoading()
      window.addEventListener('resize', myChart.resize)
      getUploadQty({
        hospitalId: this.$store.getters.hospitalId,
        year: this.year,
        quarter: this.quarter,
        month: this.month,
        startTime: this.monthRange.length > 0 ? this.monthRange[0] : '',
        endTime: this.monthRange.length > 0 ? this.monthRange[1] : '',
        departmentName: this.dept,
        doctorName: this.doc
      }).then(res => {
        if (res.code == 0) {
          if (res.data) {
            let notUploadValue = 0
            // let fillEndValue = 0
            let firstUploadValue = 0
            const auditUploadValue = 0
            // let notFillEndValue = 0

            let notUploadRate = 0
            // let fillEndRate = 0
            let firstUploadRate = 0
            const auditUploadRate = 0
            // let notFillEndRate = 0
            const summerTotal = 0
            let legendArr = []
            if (res.data.uploadQty && res.data.percentage) {
              if (res.data.uploadQty) {
                notUploadValue = res.data.uploadQty.numNotUpload ? res.data.uploadQty.numNotUpload : 0
                firstUploadValue = res.data.uploadQty.numFirstUpload ? res.data.uploadQty.numFirstUpload : 0
              }
              if (res.data.percentage) {
                notUploadRate = res.data.percentage.numNotUpload ? res.data.percentage.numNotUpload : 0
                firstUploadRate = res.data.percentage.numFirstUpload ? res.data.percentage.numFirstUpload : 0
              }
              legendArr = [{
                name: '未上报',
                value: notUploadValue,
                rate: notUploadRate
              },
              {
                name: '建档上报',
                value: firstUploadValue,
                rate: firstUploadRate
              }
              // {
              //   name: '审核上报',
              //   value: auditUploadValue,
              //   rate: auditUploadRate
              // }
              // , {
              //   name: '填写完成',
              //   value: fillEndValue,
              //   rate: fillEndRate
              // },{
              //   name: '未填写完整',
              //   value: notFillEndValue,
              //   rate: notFillEndRate
              // }
              ]
              const option = {
                color: ['#027DB4', '#F59A23', '#EC808D', '#02A7F0'],
                title: {
                  text: '填报情况分布图(总计' + (res.data.total ? res.data.total : 0) + '例)',
                  subtext: '',
                  left: 'center'
                },
                tooltip: {
                  trigger: 'item'
                },
                legend: {
                  orient: 'vertical',
                  right: 0,
                  formatter: name => {
                    let arr = []
                    arr = legendArr.filter(item => {
                      return item.name == name
                    })
                    return arr[0].name + '：' + arr[0].value + '例' + ' ' + arr[0].rate + '%'
                  }
                },
                series: [
                  {
                    name: '例数',
                    type: 'pie',
                    radius: '75%',
                    data: legendArr,
                    emphasis: {
                      itemStyle: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                      }
                    }
                  }
                ]
              }
              myChart.setOption(option)
            } else {
              myChart.showLoading({
                text: '暂无数据',
                fontSize: 18,
                left: 'center',
                color: 'transparent', // loading颜色，设置成透明或白色，不然会显示loading状态
                textColor: '#000', // 文字颜色
                maskColor: 'rgba(255, 255, 255, 0)' // 背景色
              })
            }
          }
        } else {
          myChart.showLoading({
            text: '暂无数据',
            fontSize: 18,
            left: 'center',
            color: 'transparent', // loading颜色，设置成透明或白色，不然会显示loading状态
            textColor: '#000', // 文字颜色
            maskColor: 'rgba(255, 255, 255, 0)' // 背景色
          })
        }
      })
    },
    getHaveBeenReported() {
      const haveBeenReported = document.getElementById('have-been-reported')
      const myChart = echarts.init(haveBeenReported)
      myChart.clear()
      myChart.hideLoading()
      window.addEventListener('resize', myChart.resize)
      getUploadedQty({
        hospitalId: this.$store.getters.hospitalId,
        year: this.year,
        quarter: this.quarter,
        month: this.month,
        startTime: this.monthRange.length > 0 ? this.monthRange[0] : '',
        endTime: this.monthRange.length > 0 ? this.monthRange[1] : '',
        departmentName: this.dept,
        doctorName: this.doc
      }).then(res => {
        if (res.code == 0) {
          if (res.data) {
            // let numFillEnd = 0
            let numFlowEnd = 0
            const numAwaitAuditUpload = 0
            const summerTotal = 0
            // let numFillEndRate = 0
            let numFlowEndRate = 0
            const numAwaitAuditUploadRate = 0
            let numAuditUpload = 0
            let numAuditUploadRate = 0
            let legendArr = []
            if (res.data.percentage && res.data.uploadedQty) {
              if (res.data.uploadedQty) {
                numFlowEnd = res.data.uploadedQty.numFlowEnd ? res.data.uploadedQty.numFlowEnd : 0
                numAuditUpload = res.data.uploadedQty.numAuditUpload ? res.data.uploadedQty.numAuditUpload : 0
              }
              if (res.data.percentage) {
                numFlowEndRate = res.data.percentage.numFlowEnd ? res.data.percentage.numFlowEnd : 0
                numAuditUploadRate = res.data.percentage.numAuditUpload ? res.data.percentage.numAuditUpload : 0
              }
              legendArr = [{
                name: '流程结束',
                value: numFlowEnd,
                rate: numFlowEndRate
              }, {
                name: '最终上报',
                value: numAuditUpload,
                rate: numAuditUploadRate
              }]
              const option = {
                color: ['#027DB4', '#F59A23', '#EC808D'],
                title: {
                  text: '最终上报情况分布图(小计' + (res.data.total ? res.data.total : 0) + '例)',
                  subtext: '*此部分包含于左图"建档上报"中',
                  left: 'center'
                },
                tooltip: {
                  trigger: 'item'
                },
                legend: {
                  orient: 'vertical',
                  right: 0,
                  formatter: name => {
                    let arr = []
                    arr = legendArr.filter(item => {
                      return item.name == name
                    })
                    return arr[0].name + '：' + arr[0].value + '例' + ' ' + arr[0].rate + '%'
                  }
                },
                series: [
                  {
                    name: '例数',
                    type: 'pie',
                    radius: '50%',
                    data: legendArr,
                    emphasis: {
                      itemStyle: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                      }
                    }
                  }
                ]
              }
              myChart.setOption(option)
            } else {
              myChart.showLoading({
                text: '暂无数据',
                fontSize: 18,
                left: 'center',
                color: 'transparent', // loading颜色，设置成透明或白色，不然会显示loading状态
                textColor: '#000', // 文字颜色
                maskColor: 'rgba(255, 255, 255, 0)' // 背景色
              })
            }
          }
        } else {
          myChart.showLoading({
            text: '暂无数据',
            fontSize: 18,
            left: 'center',
            color: 'transparent', // loading颜色，设置成透明或白色，不然会显示loading状态
            textColor: '#000', // 文字颜色
            maskColor: 'rgba(255, 255, 255, 0)' // 背景色
          })
        }
      })
    },
    getDeptFill() {
      const deptFill = document.getElementById('dept-fill')
      const myChart = echarts.init(deptFill)
      myChart.clear()
      myChart.hideLoading()
      window.addEventListener('resize', myChart.resize)
      getDeptUploadNumRanking({
        hospitalId: this.$store.getters.hospitalId,
        year: this.year,
        quarter: this.quarter,
        month: this.month,
        startTime: this.monthRange.length > 0 ? this.monthRange[0] : '',
        endTime: this.monthRange.length > 0 ? this.monthRange[1] : '',
        departmentName: this.dept,
        doctorName: this.doc
      }).then(res => {
        if (res.code == 0) {
          if (res.data) {
            const timeLine = []
            const uploadList = []
            if (res.data.deptUploadNums && res.data.deptUploadNums.length > 0) {
              res.data.deptUploadNums.forEach(el => {
                timeLine.push(el.departmentName ? el.departmentName : '')
                uploadList.push(el.uploadNum ? el.uploadNum : 0)
              })
              const option = {
                color: ['#027DB4', '#F59A23', '#EC808D'],
                tooltip: {
                  trigger: 'axis',
                  axisPointer: {
                    type: 'shadow'
                  }
                },
                grid: {
                  left: '3%',
                  right: '4%',
                  bottom: '3%',
                  containLabel: true
                },
                xAxis: {
                  name: '例',
                  type: 'value',
                  boundaryGap: [0, 0.01]
                },
                yAxis: {
                  type: 'category',
                  data: timeLine
                },
                series: [
                  {
                    name: '2011',
                    type: 'bar',
                    barWidth: 20,
                    label: {
                      show: true,
                      position: 'right'
                    },
                    data: uploadList
                  }
                ]
              }
              myChart.setOption(option)
            } else {
              myChart.showLoading({
                text: '暂无数据',
                fontSize: 18,
                left: 'center',
                color: 'transparent', // loading颜色，设置成透明或白色，不然会显示loading状态
                textColor: '#000', // 文字颜色
                maskColor: 'rgba(255, 255, 255, 0)' // 背景色
              })
            }
          }
        } else {
          myChart.showLoading({
            text: '暂无数据',
            fontSize: 18,
            left: 'center',
            color: 'transparent', // loading颜色，设置成透明或白色，不然会显示loading状态
            textColor: '#000', // 文字颜色
            maskColor: 'rgba(255, 255, 255, 0)' // 背景色
          })
        }
      })
    },
    getTableData() {
      this.exceedTimeData = []
      getNotUploadList({
        hospitalId: this.$store.getters.hospitalId
      }).then(res => {
        if (res.code == 0) {
          if (res.data) {
            if (res.data.overdueNotUploadList && res.data.overdueNotUploadList.length > 0) {
              this.exceedTimeData = res.data.overdueNotUploadList
            }
          }
        }
      })
    },
    view(row) {
      row.abNormal = true
      row.diseaseType = '胸痛'
      row.medicalId = 0
      const rowStr = JSON.stringify(row)
      this.$router.push({
        name: 'patientsList',
        params: {
          rowStr: rowStr
        }
      })
    },
    ignore(row) {
      this.$confirm('此操作将忽略该超期建档患者, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        ignoreUploadAlarm({
          dispatchId: row.dispatchId
        }).then(res => {
          if (res.code == 0) {
            this.getTableData()
            this.$message({
              type: 'success',
              message: '忽略该超期建档患者成功!'
            })
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消忽略'
        })
      })
    }
  }
}
</script>
